class Role < ActiveRecord::Base
  has_and_belongs_to_many :users, :as => "members", :foregin_key => "user_id"
  has_and_belongs_to_many :rights
  validates_uniqueness_of :name

  def authorized_for?(right)
    return false unless right
    rights.contains?(right)
  end
end
